package com.active.service.util;

import java.text.SimpleDateFormat;
import java.util.Random;

/**
 * @package:     com.cmsz.btms.utils
 * @date:        2017/11/22
 * @anthor:      xiaosa
 * @Description: 生成不重复20位userId
 */
public class CreateNoteId {

    /**
     * @anthor:      xiaosa
     * @date:        2017/11/22
     * @return:      string
     * @Description: 生成20位不重复随机数
     */
    public static String getNoteId() {
        long nowTime = System.currentTimeMillis();
        //获取4位年份数字
        SimpleDateFormat year = new SimpleDateFormat("yyyy");
        //获取时间戳
        String yearNumber = year.format(nowTime);
        String info = nowTime + "";
        //获取三位随机数
        int ran = 0;
        Random random = new Random();
        ran = 100 + random.nextInt(900);
        return info;
    }

    public static String getGuid() {
        long nowTime = System.currentTimeMillis();
        //获取4位年份数字
        SimpleDateFormat year = new SimpleDateFormat("yyyy");
        //获取时间戳
        String yearNumber = year.format(nowTime);
        String info = nowTime + "";
        //获取三位随机数
        int ran = 0;
        Random random = new Random();
        ran = 100 + random.nextInt(900);
        return yearNumber + info + ran;
    }

    public static void main(String[] args){
        System.out.println(getNoteId());
    }
}
